//package com.zws.cucumber.optimization.socket.wiremock;
//
//import com.github.tomakehurst.wiremock.core.FaultInjector;
//import com.github.tomakehurst.wiremock.jetty9.JettyUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import wiremock.com.google.common.base.Charsets;
//import wiremock.javax.servlet.http.HttpServletResponse;
//import wiremock.org.eclipse.jetty.server.HttpChannel;
//import wiremock.org.eclipse.jetty.server.LocalConnector;
//import wiremock.org.eclipse.jetty.server.Response;
//
//public class ZwsSocketFaultInjector implements FaultInjector {
//
//    private static final Logger logger = LoggerFactory.getLogger(ZwsSocketFaultInjector.class);
//
//    private static final byte[] GARBAGE = "lskdu018973t09sylgasjkfg1][]'./.sdlv".getBytes(Charsets.UTF_8);
//    private final Response response;
//    private final LocalConnector.LocalEndPoint endPoint;
//
//    public ZwsSocketFaultInjector(HttpServletResponse response) {
//        this.response = JettyUtils.unwrapResponse(response);
//        this.endPoint = endPoint();
//    }
//
//    @Override
//    public void connectionResetByPeer() {
//        logger.debug("connectionResetByPeer");
//        endPoint.close();
//    }
//
//    @Override
//    public void emptyResponseAndCloseConnection() {
//        throw new UnsupportedOperationException();
//    }
//
//    @Override
//    public void malformedResponseChunk() {
//        throw new UnsupportedOperationException();
//    }
//
//    @Override
//    public void randomDataAndCloseConnection() {
//        throw new UnsupportedOperationException();
//    }
//
//    private LocalConnector.LocalEndPoint endPoint() {
//        HttpChannel httpChannel = this.response.getHttpOutput().getHttpChannel();
//        return (LocalConnector.LocalEndPoint) httpChannel.getEndPoint();
//    }
//}
